/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.cmp.player;

import com.cmp.core.Main;
import com.cmp.core.constants.CollisionGroupsConstants;
import com.cmp.player.abilities.AttackControl;
import com.cmp.player.abilities.ChargeControl;
import com.cmp.player.abilities.JumpControl;
import com.cmp.player.abilities.PullControl;
import com.cmp.player.abilities.PushControl;
import com.cmp.player.abilities.ThrowControl;
import com.cmp.player.controls.AIControl;
import com.cmp.player.controls.CharacterRigidBodyControl;
import com.cmp.player.controls.CursorSelectionControl;
import com.cmp.player.controls.EnergyControl;
import com.cmp.player.controls.HealthControl;
import com.cmp.player.controls.InputControl;
import com.cmp.player.controls.MoveControl;
import com.cmp.player.controls.ScoreControl;
import com.jme3.asset.AssetManager;
import com.jme3.input.InputManager;
import com.jme3.scene.Node;

/**
 *
 * @author krummer
 */
public class PlayerFactory {
    
    public static enum Role{ CARRIER, SUPPORTER, BRAWLER };
    
    public static boolean makePlayer(Node player, boolean teamOne, Role role, boolean ai, AssetManager assets)  {
        player.setUserData("isPlayer", true);
        player.setUserData("Team", teamOne);
        
        //add Model
        player.attachChild(assets.loadModel("Models/cube.j3o"));
        
        //add physics
        CharacterRigidBodyControl body = new CharacterRigidBodyControl(1.f,2.f,1.f);
        player.addControl(body);
        body.setCollisionGroup(CollisionGroupsConstants.PLAYER);
        body.setCollideWithGroups(CollisionGroupsConstants.MAP | CollisionGroupsConstants.PLAYER | CollisionGroupsConstants.TRIGGER);
        
        //add functions
        player.addControl(new ScoreControl());
        player.addControl(new HealthControl());
        player.addControl(new EnergyControl());
        player.addControl(new JumpControl());
        player.addControl(new CursorSelectionControl());
        player.addControl(new ThrowControl());
        player.addControl(new AttackControl());
        
        /* ONLY ADD ONE OF THESE */
        switch(role) {
            case CARRIER:   player.addControl(new ChargeControl()); break;
            case SUPPORTER: player.addControl(new PullControl()); break;
            default:        player.addControl(new PushControl()); break;
        }
        
        player.addControl(new MoveControl());
        
        if(ai) {
            player.addControl(new AIControl());
        } else {
            player.addControl(new InputControl(Main.app.getInputManager()));
        }

        return true;
    }
}
